import { createRouter, createWebHistory } from 'vue-router'
import { setupRouterGuards } from './guard'

// 当前实际存在的视图组件
const routes = [
  {
    path: '/',
    component: () => import('@/views/Home.vue'), // 确保此文件存在
    meta: {
      title: '首页'
    }
  },
  {
    path: '/login',
    component: () => import('@/views/Login.vue'),
    meta: {
      title: '登录'
    }
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/NotFound.vue'),
    meta: {
      title: '页面不存在'
    }
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

// 设置路由守卫
setupRouterGuards(router)

export default router